package com.woniu.zsd.merchant.client;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.config.FeignConfig;
import com.woniu.dto.SiteListDto;
import com.woniu.form.AddSiteForm;
import com.woniu.form.UpdateSiteForm;
import com.woniu.zsd.commons.core.model.Result;
import com.woniu.zsd.merchant.entity.Site;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@FeignClient(name = "zsd-merchant", configuration = FeignConfig.class)
public interface ZsdMerchantClient {

    // 站点集合分页查询
    @GetMapping("/site/list")
    Result<Page<Site>> siteList(
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
            @RequestParam(value = "pageNum", required = false) Integer pageNum,
            @RequestParam(value = "status", required = false) Integer status,
            @RequestParam(value = "name", required = false) String name
    );

    // 添加站点
    @PostMapping("/site/add")
    Result addSite(@Valid @RequestBody AddSiteForm addSiteForm);

    // 删除站点
    @DeleteMapping("/site/delete")
    Result deleteSite(@RequestParam(value = "id") Integer id);

    // 修改站点信息
    @PutMapping("/site/update")
    Result updateSite(@Valid @RequestBody UpdateSiteForm updateSiteForm);

    // 根据经纬度查询五公里以内的站点
    @GetMapping("/site/recent")
    Result<List<Integer>> recentSiteId(@RequestParam(value = "longitude") Double longitude, @RequestParam(value = "latitude") Double latitude);

    // 根据ID查询站点
    @GetMapping("/site/find/id")
    Result<SiteListDto> findSiteById(@RequestParam(value = "id") Integer id);
}